package com.android.server.roobo;

import java.io.File;
import java.util.ArrayList;
import java.util.List;


public class RobotNVRomDataLocalJni {

    private static final String NVROM_BLOCK_DEV = "/dev/block/platform/ff0f0000.dwmmc/by-name/privdata";
    private static RobotNVRomDataLocalJni sInstance;

    private RobotNVRomDataLocalJni() {
    }

    public static synchronized RobotNVRomDataLocalJni getInstance() {
        if (sInstance == null) {
            sInstance = new RobotNVRomDataLocalJni();
        }
        return sInstance;
    }

    public boolean isExistNVROM() {
        File file = new File(NVROM_BLOCK_DEV);
        return file.exists() && file.canRead() && file.canWrite();
    }


    /**
     * @param key   max length of key is 64
     * @param value
     * @return
     */
    public native boolean setIntegerNVRom(String key, int value);

    public native int getIntegerNVRom(String key, int defValue);

    public native boolean removeIntegerNVRom(String key);

    public native NVRomIntegerInfo[] getAllIntegerNVRom(int startOffset, int count);

    public native int getCountOfAllIntegerNVRom();

    /**
     * @param key    max length of key is 64
     * @param string max length of string is 1024
     * @return
     */
    public native boolean setStringNVRom(String key, String string);

    public native String getStringNVRom(String key);

    public native boolean removeStringNVRom(String key);

    public native NVRomStringInfo[] getAllStringNVRom(int startOffset, int count);

    public native int getCountOfAllStringNVRom();

    static {
        System.loadLibrary("NVRomData");
    }


}
